import React from 'react'
import { NavBar, Space, Toast } from 'antd-mobile';
import { SearchOutline, MoreOutline, CloseOutline } from 'antd-mobile-icons'
import { useNavigate } from 'react-router-dom'
type Props = {
    title: string,
    isshow: boolean,
    righttitle?: string
    callback?: () => void
}

export default function Navheader({ title, isshow, righttitle, callback }: Props) {

    const navigate = useNavigate();
    const right = (
        <div style={{ fontSize: 24 }}>
            <Space style={{ '--gap': '16px', fontSize: '18px' }}>
                <p onClick={() => {
                    // 调用函数
                    (callback as () => void)()
                }}>{righttitle}</p>
            </Space>
        </div>
    )
    const back = () => navigate(-1)


    return (
        <NavBar right={isshow ? right : ''} onBack={back}>
            {title}
        </NavBar>
    )
}